package com.eric.test.thread.method;

/**
 * @description:
 * @author: liuBing
 * @create: 2024-06-17 09:50
 **/
public class Join {

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
            System.out.println("子线程1 开始执行");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            System.out.println("子线程1 sleep over");
        });

        Thread thread2 = new Thread(() -> {
            System.out.println("子线程2 开始执行");

        });

        thread1.start();
        // thread1 执行完成之后 再执行 thread2
        thread1.join();
        //
        thread2.start();

    }
}
